//
//  NMyThemeViewController.m
//  News
//
//  Created by zhangtao on 2018/10/16.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "NMyThemeViewController.h"
#import "NWalletDetailHeaderView.h"
#import "NMyThemeFocusCell.h"
#import "NThemeAuditCell.h"

@interface NMyThemeViewController ()<UITableViewDelegate,UITableViewDataSource>

#define foucsPerson @"foucsPerson"
#define auditCell @"auditCell"

@property(nonatomic,strong)UITableView *table;
@property(nonatomic,assign)NSInteger type;
@end

@implementation NMyThemeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"我的主题";
    NWalletDetailHeaderView *top = [[NWalletDetailHeaderView alloc]initWithFrame:CGRectMake(0, navHeight, ACEWidth, 40) items:@[@"文章审核",@"关注用户",@"主题资料"]];
    [self.view addSubview:top];
    WEAKSELF;
    top.WalletDetailViewCallBack = ^(NSInteger tag) {
        weakSelf.type = tag;
        [weakSelf.table reloadData];
    };
    
    _table = [[UITableView alloc]initWithFrame:CGRectMake(0, navHeight+40, ACEWidth, ACEHeight-navHeight-40)  style:UITableViewStyleGrouped];
    _table.backgroundColor = [UIColor whiteColor];
    _table.delegate = self;
    _table.dataSource = self;
    [self.view addSubview:_table];
    [_table registerNib:[UINib nibWithNibName:@"NMyThemeFocusCell" bundle:nil] forCellReuseIdentifier:foucsPerson];
    [_table registerNib:[UINib nibWithNibName:@"NThemeAuditCell" bundle:nil] forCellReuseIdentifier:auditCell];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (_type == 0) {
        UITableViewCell *cell = [self tableView:_table cellForRowAtIndexPath:indexPath];
        return cell.frame.size.height;
    }else{
        return 45;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return .1;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (_type == 0) {
        NThemeAuditCell *cell = [tableView dequeueReusableCellWithIdentifier:auditCell];
        cell.themeTitle = @"阿斯顿了房间里；阿时间快到风口浪尖看老师；阿都放假了拉萨地方";
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;
    }
//    else if (_type == 1){
        NMyThemeFocusCell *cell = [tableView dequeueReusableCellWithIdentifier:foucsPerson];
        return cell;
//    }else if (_type == 2){
//
//    }
}

@end
